package com.litign.personcontrol.controller;

import com.litign.personcontrol.pojo.Dept;
import com.litign.personcontrol.pojo.Result;

import java.util.List;


import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger.*;

import com.litign.personcontrol.service.DeptService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


//@Slf4j
@RestController
@RequestMapping("/depts")
public class DeptController {
    @Autowired
    private DeptService deptService;


    private static final Logger log = LoggerFactory.getLogger(DeptController.class);


    @GetMapping
    public Result list() {
        System.out.println("开hi了");
        List<Dept> deptList = deptService.list();
        return Result.success(deptList);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        log.info("根据id删除部门：{}",id);
        deptService.delete(id);
        return Result.success();
    }

    @PostMapping
    public Result add(@RequestBody Dept dept) {
        log.info("新增部门：{}",dept);
        deptService.add(dept);
        return Result.success();
    }







}
